package com.lcx.plugin.neteaseCloud.component.toolwindow;

import javax.swing.*;
import java.awt.*;

/**
 * @author daxiong
 * @date 2021/9/15 下午4:08
 */
public class ImagePanel extends JPanel {

    private ImageIcon ic;
    private CustomRectangle customRectangle;

    public ImagePanel(ImageIcon ic, CustomRectangle customRectangle) {
        this.ic = ic;
        this.customRectangle = customRectangle;
    }

    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        // 下面这行是为了背景图片可以跟随窗口自行调整大小
        g.drawImage(ic.getImage(), customRectangle.getX(), customRectangle.getY(),
                customRectangle.getWidth(), customRectangle.getHeight(), this);
    }

    public ImageIcon getIc() {
        return ic;
    }

    public void setIc(ImageIcon ic) {
        this.ic = ic;
    }

    public CustomRectangle getCustomRectangle() {
        return customRectangle;
    }

    public void setCustomRectangle(CustomRectangle customRectangle) {
        this.customRectangle = customRectangle;
    }
}
